package com.origin.utils;

import android.graphics.drawable.Drawable;
import android.util.Log;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.databinding.BindingAdapter;

import com.origin.utils.image.ImageLoader;
import com.origin.utils.log.LogUtils;
import com.origin.utils.time.TimeUtil;

public class DataBindingUtils {

    @BindingAdapter(value = {"imageUrl", "placeholder", "error"}, requireAll = false)
    public static void loadImage(ImageView imageView, String url, Drawable placeholder, Drawable error) {
        Log.e("加载的图片","url  "+url );
        ImageLoader.loaderImg(
                imageView.getContext(),
                url,
                placeholder,
                error, null
        ).into(imageView);
    }

    @BindingAdapter({"durationTime"})
    public static void getDurationTime(TextView textView, int length) {
        textView.setText(TimeUtil.INSTANCE.secondToTime((long) length));
    }

}
